home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / WMS.CAB / wmscommon.inc < prev    next >
Encoding:
Text File  |  2003-02-21  |  21.8 KB  |  725 lines

  1. <%
  2. '+-------------------------------------------------------------------------
  3. '
  4. '  Microsoft Windows Media
  5. '  Copyright (C) Microsoft Corporation. All rights reserved.
  6. '
  7. '  File:       common.inc
  8. '
  9. '  Contents:    Included by nearly all WMS Admin .asp files
  10. '
  11. '--------------------------------------------------------------------------
  12.  
  13. if( 0 = Len( CStr( Session( "BaseHREF" ) ) ) ) then
  14.     Session( "BaseHREF" ) = Request.ServerVariables( "HTTP_HOST" )
  15. end if
  16.  
  17. on error resume next
  18. Set s_WMSAdmin = Session( "WMSAdmin" )
  19. if( ( null = s_WMAdmin ) or IsEmpty( s_WMSAdmin ) ) then
  20.     Set s_WMSAdmin = Server.CreateObject("WMSAdminRemote.ASPAdmin")
  21.     Set Session("WMSAdmin") = s_WMSAdmin
  22. end if
  23.  
  24. '///////////////////////////
  25. Sub BrowserSniff()
  26.     if( 0 = Len( Session( "BrowserVersion" ) ) ) then
  27.  
  28.         Dim strBrowser
  29.         Dim objBrowseCap
  30.         
  31.         err.Clear
  32.         
  33.         g_dwBrowserType = brUnknown
  34.         g_curBrowserVersion = 0
  35.         g_strUserAgent = Request.ServerVariables( "HTTP_USER_AGENT" )
  36.       
  37.         Set objBrowseCap = Server.CreateObject( "MSWC.BrowserType" )
  38.         if( 0 = err.number ) then
  39.             strBrowser = objBrowseCap.browser
  40.             if( 0 = StrComp( "IE", strBrowser, vbTextCompare ) ) then
  41.                 g_dwBrowserType = brMSIE
  42.             elseif( 0 = StrComp( "Netscape", strBrowser, vbTextCompare ) ) then
  43.                 g_dwBrowserType = brNetscape
  44.             elseif( 0 = StrComp( "Opera", strBrowser, vbTextCompare ) ) then
  45.                 g_dwBrowserType = brOpera
  46.             end if
  47.             
  48.             g_curBrowserVersion = CCur( objBrowseCap.version )
  49.         end if
  50.  
  51.         if( brUnknown = g_dwBrowserType ) then
  52.             if( 0 < InStr( 1, g_strUserAgent, "MSIE", vbTextCompare ) ) then 
  53.                 g_dwBrowserType = brMSIE
  54.                 g_curBrowserVersion = CCur( Mid( g_strUserAgent, InStr( 1, g_strUserAgent, "MSIE", vbTextCompare ) + 5, 3 ) )
  55.                 if( 0 >= g_curBrowserVersion ) then
  56.                     g_curBrowserVersion = CCur( Mid( g_strUserAgent, InStr( 1, g_strUserAgent, "MSIE", vbTextCompare ) + 5, 1 ) )
  57.                 end if
  58.             elseif( 0 < InStr( 1, g_strUserAgent, "Opera", vbTextCompare ) ) then
  59.                 g_dwBrowserType = brOpera
  60.                 g_curBrowserVersion = CCur( Mid( g_strUserAgent, InStr( 1, g_strUserAgent, "Opera", vbTextCompare ) + 6, 1 ) )
  61.             else
  62.                 g_dwBrowserType = brNetscape
  63.                 if( 0 < InStr( 1, g_strUserAgent, "Gecko", vbTextCompare ) ) then
  64.                     g_curBrowserVersion = CCur( Mid( g_strUserAgent, 9, 1 ) )
  65.                 else
  66.                     g_curBrowserVersion = CCur( Mid( g_strUserAgent, InStrRev( g_strUserAgent, "/", -1, vbTextCompare ) + 1, 1 ) )
  67.                     if( 0 = g_curBrowserVersion ) then
  68.                         g_curBrowserVersion = CCur( Mid( g_strUserAgent, InStr( g_strUserAgent, "/", -1, vbTextCompare ) + 1, 1 ) )
  69.                         if( 2 >= g_curBrowserVersion ) then
  70.                             if( 0 < InStr( 1, g_strUserAgent, "Gecko", vbTextCompare ) ) then
  71.                                 g_curBrowserVersion = CCur( "5.0" )
  72.                             end if
  73.                         end if
  74.                     end if
  75.                 end if
  76.             end if
  77.         end if
  78.  
  79.         Session( "UserAgent" ) = g_strUserAgent
  80.         Session( "BrowserType" ) = g_dwBrowserType        
  81.         Session( "BrowserVersion" ) = g_curBrowserVersion
  82.     else
  83.         g_strUserAgent = Session( "UserAgent" )
  84.         g_dwBrowserType = Session( "BrowserType" )
  85.         g_curBrowserVersion = Session( "BrowserVersion" )
  86.     end if
  87.  
  88.     ' Set depricated flags
  89.     if( brMSIE = g_dwBrowserType ) then
  90.         g_bMSIE = TRUE
  91.         g_bNetscape = FALSE
  92.         g_bOpera = FALSE
  93.     elseif( brNetscape = g_dwBrowserType ) then
  94.         g_bMSIE = FALSE
  95.         g_bNetscape = TRUE
  96.         g_bOpera = FALSE
  97.     elseif( brOpera = g_dwBrowserType ) then
  98.         g_bMSIE = FALSE
  99.         g_bNetscape = FALSE
  100.         g_bOpera = TRUE
  101.     end if
  102. End Sub
  103.  
  104.  
  105. '///////////////////////////
  106. Sub PickStyleSheet()
  107.     BrowserSniff
  108.     
  109.     g_dwBrowserType = Session( "BrowserType" )
  110.     if( 0 = Len( Session( "cssName" ) ) ) then
  111.         if( brMSIE = g_dwBrowserType ) then
  112.             if( MIN_MSIE_VERSION <= g_curBrowserVersion ) then
  113.                 if( 0 >= InStr( g_strUserAgent, "Windows" ) ) then
  114.                     Session( "cssName" ) = "css/wms_macie_admin.css"
  115.                 else
  116.                     Session( "cssName" ) = "css/wmsadmin.css"
  117.                 end if
  118.             end if
  119.         elseif( brNetscape = g_dwBrowserType ) then
  120.             if( MIN_NSCP_VERSION <= g_curBrowserVersion ) then
  121.                 Session( "cssName" ) = "css/wms_ns6_admin.css"
  122.             end if
  123.         elseif( brOpera = g_dwBrowserType ) then
  124.             if( MIN_OPERA_VERSION <= CCur( g_curBrowserVersion ) ) then
  125.                 Session( "cssName" ) = "css/wms_ns6_admin.css"
  126.             end if
  127.         else
  128.             Session( "cssName" ) = "css/wmsadmin.css"
  129.         end if
  130.     end if
  131. End Sub
  132.  
  133.  
  134. '///////////////////////////
  135. Sub RedirectIfLegacyBrowser()    
  136.     Dim bDepricatedBrowser
  137.     Dim curMinSupportedVersion
  138.     bDepricatedBrowser = FALSE
  139.     
  140.     BrowserSniff
  141.  
  142.     g_curBrowserVersion = Session( "BrowserVersion" )
  143.     g_dwBrowserType = Session( "BrowserType" )
  144.     if( brMSIE = g_dwBrowserType ) then
  145.         curMinSupportedVersion = CCur( MIN_MSIE_VERSION )
  146.     elseif( brNetscape = g_dwBrowserType ) then
  147.         curMinSupportedVersion = CCur( MIN_NSCP_VERSION )
  148.     elseif( brOpera = g_dwBrowserType ) then
  149.         curMinSupportedVersion = CCur( MIN_OPERA_VERSION )
  150.     else
  151.         curMinSupportedVersion = "255"
  152.         bDepricatedBrowser = TRUE
  153.     end if
  154.  
  155.     if( FALSE = bDepricatedBrowser ) then
  156.         bDepricatedBrowser = CBool( curMinSupportedVersion > CCur( g_curBrowserVersion ) )
  157.     end if    
  158.  
  159.     if( TRUE = bDepricatedBrowser ) then
  160.         Response.Redirect( "/oldBrowser.asp" )
  161.         Response.Flush
  162.         Response.End
  163.     end if
  164. End Sub
  165.  
  166. '///////////////////////////
  167. Sub DisableContextMenu()
  168.     if( brMSIE = g_dwBrowserType ) then
  169.         Response.Write( "document.oncontextmenu=" & chr( 34 ) & "return true;event.cancelBubble=true;return false;" & chr(34) & "; " )
  170.     else
  171.         Response.Write( "document.onmouseup=" & chr( 34 ) & chr( 34) & "; " )
  172.     end if
  173. End Sub
  174.  
  175. '///////////////////////////
  176. '
  177. '  Determines if the the localhost is running the WMS service and
  178. '   builds the local IP address and the local server name.  Sets
  179. '   the following globals:
  180. '
  181. '       g_strLocalHostName, g_strLocalHostDNSName, g_strLocalHostIP, g_bLocalHostRunningWMS
  182. '
  183. '  We then cache these values into application state, since they're not
  184. '   likely to change throughout the course of execution
  185. '
  186. Sub SyncWithApplicationState()
  187.     
  188.     if( 0 = Len( Application( "strLocalHostName" ) ) ) then
  189.         Dim strServerName
  190.         Dim strServerDNSName
  191.         Dim strServerIP
  192.         Dim strDomainName
  193.         Dim dwConnectionFailureCode
  194.  
  195.         strServerName = s_WMSAdmin.GetCanonicalComputerName( "localhost", WMS_ComputerNameNetBIOS )
  196.         strServerDNSName = s_WMSAdmin.GetCanonicalComputerName( "localhost", WMS_ComputerNameDnsFullyQualified )    
  197.         strDomainName = s_WMSAdmin.GetCanonicalComputerName( "localhost", WMS_ComputerNameDnsDomain )
  198.         
  199.         if( 0 = Len( strServerName ) )then
  200.             strServerName = strServerDNSName
  201.             if( 0 = Len( strServerName ) ) then
  202.                 strServerName = "localhost"
  203.             end if
  204.         end if
  205.         
  206.         if( 0 = StrComp( "127.0.0.1", strServerName, vbTextCompare ) ) then
  207.             strServerName = "localhost"
  208.             strServerIP = "127.0.0.1"
  209.         else
  210.             strServerIP = s_WMSAdmin.ResolveToIP( strServerName )
  211.         end if
  212.         
  213.         dwConnectionFailureCode = s_WMSAdmin.GetServiceStatus( strServerName )
  214.         if( WMS_SERVICE_STOPPED = dwConnectionFailureCode ) or _
  215.         ( WMS_SERVICE_STARTED = dwConnectionFailureCode ) or _
  216.         ( WMS_SERVICE_INERROR = dwConnectionFailureCode ) or _
  217.         ( WMS_SERVICE_FAILEDTOSTART = dwConnectionFailureCode ) then
  218.             g_bLocalHostRunningWMS = TRUE   ' is the service installed on the box, regardless of whether or not it works
  219.         else
  220.             g_bLocalHostRunningWMS = FALSE
  221.         end if
  222.         
  223.         g_strLocalHostName = strServerName
  224.         g_strLocalHostDNSName = strServerDNSName
  225.         g_strLocalHostIP = strServerIP
  226.         g_strDomainName = strDomainName
  227.  
  228.         ' Cache these values into application state
  229.         
  230.         Application.Lock
  231.         Application( "strLocalHostName" ) = g_strLocalHostName
  232.         Application( "strLocalHostDNSName" ) = g_strLocalHostDNSName
  233.         Application( "strDomainName" ) = g_strDomainName
  234.         Application( "strHostIPAddress" ) = g_strLocalHostIP
  235.         Application( "bLocalHostHasWMS" ) = g_bLocalHostRunningWMS
  236.         Application.Unlock
  237.  
  238.     end if
  239.     if( 0 = Len( Session( "strLocalHostName" ) ) ) then
  240.  
  241.         ' Cache these values into session state
  242.         
  243.         Application.Lock
  244.         Session( "strLocalHostName" ) = Application( "strLocalHostName" )
  245.         Session( "strLocalHostDNSName" ) = Application( "strLocalHostDNSName" )
  246.         Session( "strDomainName" ) = Application( "strDomainName" )
  247.         Session( "strHostIPAddress" ) = Application( "strHostIPAddress" )
  248.         Session( "bLocalHostHasWMS" ) = Application( "bLocalHostHasWMS" )
  249.         Application.Unlock
  250.         
  251.     end if
  252.  
  253.     g_strLocalHostName = Session( "strLocalHostName" )
  254.     g_strLocalHostDNSName = Session( "strLocalHostDNSName" )
  255.     g_strDomainName = Session( "strDomainName" )
  256.     g_strLocalHostIP = Session( "strHostIPAddress" )
  257.     g_bLocalHostRunningWMS = Session( "bLocalHostHasWMS" )
  258.  
  259. End Sub
  260.  
  261. '///////////////////////////
  262. Function BoolToText( bValue )
  263.     if( bValue ) then
  264.         BoolToText = "true"
  265.     else
  266.         BoolToText = "false"
  267.     end if
  268. End Function
  269.  
  270.  
  271. '///////////////////////////
  272. ' RemoveSpecifiedChars
  273. ' -------------
  274. ' eliminates bad characters specified in second argument.  
  275. ' See http://support.microsoft.com/support/kb/articles/Q252/9/85.ASP
  276. Function RemoveSpecifiedChars( strInput, strPattern )
  277.     Dim RegEx
  278.     Set regEx = New RegExp
  279.     regEx.Pattern = strPattern
  280.     regEx.IgnoreCase = TRUE
  281.     regEx.Global = TRUE
  282.     regEx.Multiline = TRUE
  283.     RemoveSpecifiedChars = regEx.Replace( strInput, "" )
  284. End Function
  285.  
  286. '///////////////////////////
  287. ' ContainsSpecifiedChars
  288. ' -------------
  289. ' detects specified characters specified in second argument.  
  290. ' See http://support.microsoft.com/support/kb/articles/Q252/9/85.ASP
  291. Function DetectSpecifiedChars( strInput, strPattern )
  292.     Dim RegEx
  293.     Set regEx = New RegExp
  294.     regEx.Pattern = strPattern
  295.     regEx.IgnoreCase = TRUE
  296.     regEx.Global = TRUE
  297.     regEx.Multiline = TRUE
  298.     DetectSpecifiedChars = regEx.Test( strInput )
  299. End Function
  300.  
  301. '///////////////////////////
  302. ' RemoveDangerousCharacters
  303. ' -------------
  304. ' eliminates bad characters.  See http://support.microsoft.com/support/kb/articles/Q252/9/85.ASP
  305. Function RemoveDangerousCharacters( strInput )
  306.     Dim regEx
  307.     Set regEx = New RegExp
  308.     regEx.Pattern = REGEXP_DANGEROUS_CHARS
  309.     regEx.IgnoreCase = TRUE
  310.     regEx.Global = TRUE
  311.     regEx.Multiline = TRUE
  312.     strInput = Replace( strInput, chr(34), "" ) ' quotes are never allowed
  313.     RemoveDangerousCharacters = regEx.Replace( strInput, "" )
  314. End Function
  315.  
  316.  
  317. '///////////////////////////
  318. ' SpacesToNonbreak
  319. ' -------------
  320. ' replaces spaces with nbsp characters
  321.  
  322. Function SpacesToNonbreak( strInput )
  323.     Dim regEx
  324.     Set regEx = New RegExp
  325.     regEx.Pattern = "\s"
  326. '    regEx.Pattern = " "
  327.     regEx.IgnoreCase = TRUE
  328.     regEx.Global = TRUE
  329.     regEx.Multiline = TRUE
  330.     SpacesToNonbreak = regEx.Replace( strInput, " " )
  331. End Function
  332.  
  333.  
  334. '///////////////////////////
  335. ' EscBackslashChar
  336. ' -------------
  337. ' make many strings safe for client-side script
  338.  
  339. Function EscBackslashChar( strInput )
  340.     Dim regEx
  341.     Set regEx = New RegExp
  342.     regEx.Pattern = "\x005C"
  343.     regEx.IgnoreCase = TRUE
  344.     regEx.Global = TRUE
  345.     regEx.Multiline = TRUE
  346.     EscBackslashChar = regEx.Replace( strInput, "\\" )
  347. End Function
  348.  
  349. '///////////////////////////
  350. ' DashesToNonbreak
  351. ' -------------
  352. ' replaces dashes with non-break escaped characters
  353.  
  354. Function DashesToNonbreak( strInput )
  355.     Dim regEx
  356.     Set regEx = New RegExp
  357.     regEx.Pattern = "\x002D|\x00AD"
  358. '    regEx.Pattern = " "
  359.     regEx.IgnoreCase = TRUE
  360.     regEx.Global = TRUE
  361.     regEx.Multiline = TRUE
  362.     DashesToNonbreak = regEx.Replace( strInput, "−" )
  363. End Function
  364.  
  365.  
  366. '///////////////////////////
  367. ' TrimFileColon
  368. ' -------------
  369. ' For file paths, we don't wish to display the "file://" prefix.  So, 
  370. '  we trim it from the string using this function.
  371.  
  372. Function TrimFileColon( url )
  373.     Dim dwOffset
  374.     
  375.     if( 0 = StrComp( Left( url, Len( L_FILECOLON_TEXT ) ), L_FILECOLON_TEXT, vbTextCompare ) ) then
  376.         dwOffset = Len( L_FILECOLON_TEXT ) + 1
  377.         TrimFileColon = Mid( url, dwOffset, Len( url ) - dwOffset + 1 )
  378.     else
  379.         TrimFileColon = url
  380.     end if
  381. End Function
  382.  
  383.  
  384.  
  385. '///////////////////////////
  386. ' URLDecode
  387. ' -------------
  388. ' attempts to undo a javascript escape() call or a Server.HTMLEncode or a Server.URLEncode
  389.  
  390. Function URLDecode( url )
  391.     temp = url
  392.     x = InStr( temp, "%")
  393.     Do While x > 0
  394.         URLDecode = URLDecode & Left( temp, x-1 )
  395.         URLDecode = URLDecode & Chr( CLng( "&H" & Mid( temp, x+1, 2 ) ) )
  396.         temp = Mid( temp, x+3 )
  397.         x = InStr( temp, "%" )
  398.     Loop
  399.     URLDecode = URLDecode + temp
  400. End Function
  401.  
  402.  
  403. '///////////////////////////
  404. ' PPNameToIndex
  405. ' -------------
  406. ' returns the index of the requested pub point, specified by publishing point "name"
  407.  
  408. Function PPNameToIndex( byRef WMS, byRef strPPName )
  409.     Dim i
  410.     Dim iNumVRoots
  411.     Dim bFound
  412.     Dim strUnescapedName
  413.     
  414.     strUnescapedName = SafeUnescape( strPPName )
  415.     
  416.     bFound = FALSE
  417.     iNumVRoots = WMS.PublishingPoints.Count
  418.  
  419.     PPNameToIndex = -1
  420.     if ( 0 = StrComp( strUnescapedName, L_DEFAULTPPNAME_TEXT, vbTextCompare ) ) then
  421.         strUnescapedName = "/"
  422.         strPPName = "/"
  423.     elseif( 0 = StrComp( strUnescapedName, L_DEFAULTOD_TEXT, vbTextCompare ) ) then
  424.         strUnescapedName = "/"
  425.     elseif( 0 = StrComp( strUnescapedName, L_DEFAULTBC_TEXT, vbTextCompare ) ) then
  426.         strUnescapedName = "/"
  427.     end if
  428.     
  429.     for i = 0 to iNumVRoots - 1
  430.         if( 0 = StrComp( strUnescapedName, WMS.PublishingPoints.Item(i).Name, vbTextCompare ) ) then
  431.             PPNameToIndex = i
  432.             bFound = TRUE
  433.             Exit For
  434.         end if
  435.     next
  436.  
  437.     ' Unlikely, but the name of the pub point could have been mangled by the encoding, so try the raw form
  438.     if not bFound then
  439.         for i = 0 to iNumVRoots - 1
  440.             if( 0 = StrComp( strPPName, WMS.PublishingPoints.Item(i).Name, vbTextCompare ) ) then
  441.                 PPNameToIndex = i
  442.                 bFound = TRUE
  443.                 Exit For
  444.             end if
  445.         next
  446.     end if
  447.     
  448. End Function
  449.  
  450.  
  451. '///////////////////////////
  452. ' PPIDToIndex
  453. ' -------------
  454. ' returns the index of the requested pub point, specified by publishing point "ID" -- its GUID
  455.  
  456. Function PPIDToIndex( byRef pServer, byRef strPPID )
  457.     Dim i
  458.     Dim iNumVRoots
  459.  
  460.     iNumVRoots = pServer.PublishingPoints.Count
  461.  
  462.     PPIDToIndex = -1
  463.     for i = 0 to iNumVRoots - 1
  464.         if( 0 = StrComp( strPPID, pServer.PublishingPoints.Item(i).ID, vbTextCompare ) ) then
  465.             PPIDToIndex = i
  466.             Exit Function
  467.         end if
  468.     next
  469.  
  470. End Function
  471.  
  472.  
  473. '///////////////////////////
  474. ' ConvertPPName
  475. ' -------------
  476. ' Converts the name of the default pub point, if detected, away from Slash into something more friendly
  477.  
  478. Function ConvertPPName( strPPName, dwType )
  479.     if ( 0 = StrComp( "/", strPPName, vbTextCompare ) ) then
  480.         ConvertPPName = L_DEFAULTPPNAME_TEXT
  481.         
  482.     else 
  483.         ConvertPPName = strPPName
  484.     end if
  485. End Function
  486.  
  487.  
  488. '///////////////////////////
  489. ' ConvertPPName
  490. ' -------------
  491. ' Converts the friendly name of the default pub point, if detected, back to Slash
  492.  
  493. Function UnconvertPPName( strPPName )
  494.     if ( 0 = StrComp( L_DEFAULTPPNAME_TEXT, strPPName, vbTextCompare ) ) then
  495.         UnconvertPPName = "/"
  496.     else 
  497.         UnconvertPPName = strPPName
  498.     end if
  499. End Function
  500.  
  501. '///////////////////////////
  502. ' jsTRY
  503. ' -------------
  504. ' Simple macro to generate client-side JScript exception handling -- the Try part
  505.  
  506. Sub jsTRY()
  507. %>
  508. /*@if (@_jscript_version >= 1.3)
  509.     try 
  510.     {
  511. @end @*/
  512. <%
  513. End Sub
  514.  
  515. '///////////////////////////
  516. ' jsCATCH
  517. ' -------------
  518. ' Simple macro to generate client-side JScript exception handling -- the Catch part
  519. '  Change the value of the variable "g_bDebugMode" in wmscommon.js to have this pop up
  520. '  error dialogs as opposed to quietly suppressing them.  Useful for debugging.
  521.  
  522. Sub jsCATCH()
  523. %>
  524. /*@if (@_jscript_version >= 1.3)
  525.     } 
  526.     catch( e )
  527.     {<% if g_bDebugMode then
  528.             if brMSIE <> g_dwBrowserType then 
  529.                 if( g_bShowJSErrorDialogs ) then %>
  530.         window.alert( "Err description: " + e.message );<%
  531.                 end if
  532.             else %>
  533.         throw( e );<%
  534.             end if
  535.         end if %>
  536.     }
  537. @end @*/
  538. <%
  539. End Sub
  540. %>
  541. <script language="JavaScript" runat=SERVER>
  542. /*@cc_on @*/
  543.  
  544. ///////////////////////////
  545. function SafeUnescape( szInput )
  546. {
  547.     var szRetVal = new String( szInput );
  548.     
  549.     if( 0 == szRetVal.length )
  550.     {
  551.         return( "" );
  552.     }
  553.     
  554. /*@if (@_jscript_version >= 5.5)
  555.     szRetVal = decodeURIComponent( szRetVal );
  556.    @else @*/
  557.     szRetVal = unescape( szRetVal );
  558. /*@end @*/
  559.     return( szRetVal );
  560. }
  561.  
  562. ///////////////////////////
  563. function SafeEscape( szInput )
  564. {
  565.     var szRetVal = new String( szInput );
  566.     if( 0 == szRetVal.length )
  567.     {
  568.         return( "" );
  569.     }
  570.     
  571.     // prevent dbl-escape bugs
  572.     szUnescapedVal = SafeUnescape( szInput );
  573.     if( szUnescapedVal != szInput )
  574.     {
  575.         return( szInput );
  576.     }
  577.     
  578. /*@if (@_jscript_version >= 5.5)
  579.     szRetVal = encodeURIComponent( szRetVal );
  580.    @else @*/
  581.     szRetVal = escape( szRetVal );
  582. /*@end @*/
  583.     return( szRetVal );
  584. }
  585.  
  586. ///////////////////////////
  587. //
  588. // Take a UTC date and format so that it doesn't get coerced into being local to IIS
  589. //
  590. function FormatDateAsUTC( szInput )
  591. {
  592. /*
  593.     var dateUTC;
  594.     dateUTC = new Date( szInput );
  595.     return( dateUTC.toUTCString() );
  596. */
  597.     var dateInput;
  598.     var dateUTC;
  599.  
  600.     var dateNow;
  601.     var tzOffset;
  602.     var dwOffsetInHours;
  603.     var dwOffsetInMinutes;
  604.  
  605.     dateNow = new Date();
  606.     tzOffset = dateNow.getTimezoneOffset();
  607.     dwOffsetInHours = tzOffset / 60;
  608.     dwOffsetInMinutes = tzOffset - ( dwOffsetInHours * 60 );
  609.  
  610.     dateInput = new Date( szInput );
  611.         
  612.     dateUTC = new Date( dateInput );
  613.     dateUTC.setUTCHours( dateInput.getUTCHours() - dwOffsetInHours );
  614.     dateUTC.setUTCMinutes( dateInput.getUTCMinutes() - dwOffsetInMinutes );
  615.     
  616.     return( dateUTC.toUTCString() );
  617. }
  618. </script>
  619.  
  620. <%
  621. '///////////////////////////
  622. Sub WriteCommonJSUtils()
  623.     on error resume next
  624.  
  625.     DisableContextMenu
  626. %>
  627.  
  628. ///////////////////////////
  629. function ShowServerList()
  630. {
  631.     <% jsTRY %>
  632.         window.open( "/wmssecure/index.asp?show=true", "sList", "hotkeys,scrollbars,status,menubar,resizable", true );
  633.     <% jsCATCH %>
  634. }
  635. <%
  636.     if( FALSE = g_bSecureConnection ) then %>
  637.  
  638. ///////////////////////////
  639. function ShowHideSecureWarning( szPathToImg )
  640. {
  641.     <% jsTRY %>
  642.     if( parent.frames && parent.frames[ "treeFrames" ] )
  643.     {
  644.         if( parent.frames && parent.frames[ "treeFrames" ].frames[ "frameTreeCode" ] )
  645.         {
  646.             return;
  647.         }
  648.     }
  649.     document.write( "<td align=left valign=top>" );
  650.     document.write( "<a href=\"" + document.location.protocol + "//" + parent.document.location.host + "/nonsecure.asp" + "\" target=\"sList\" style=\"position:absolute;right:15;top:10\" border=0><img alt=\"<%= Server.HTMLEncode( L_NONSECUREWARNING_TEXT ) %>\" border=\"0\" src=\"" + szPathToImg + "\"></a>" );
  651.     document.write( "</td> " );
  652.     <% jsCATCH %>
  653. }
  654. <%
  655.     end if
  656.  
  657.     BrowserSniff
  658.     if brMSIE = g_dwBrowserType then 
  659. %>
  660.  
  661. ///////////////////////////
  662. function UpdateTreeViewSelection()
  663. {
  664.     <% jsTRY %>
  665.     var childFrame;
  666.     childFrame = window.parent.frames[ "treeFrames" ];
  667.     if( childFrame )
  668.     {
  669.         childFrame = window.parent.frames[ "treeFrames" ].frames[ "frameTreeCode" ];
  670.     }
  671.     if( childFrame )
  672.     {<%
  673.         Dim strTOCEntry
  674.     
  675.         if( IsEmpty( g_strPubPointID ) or ( 0 < Len( g_strPubPointID ) ) ) then
  676.             strTOCEntry = g_strPubPointID
  677.         else
  678.             if( 0 < InStr( 1, Request.ServerVariables( "PATH_INFO" ), "server_diag", vbTextCompare ) ) then
  679.                 strTOCEntry = "diag"
  680.             else
  681.                 strTOCEntry = "server"
  682.             end if
  683.         end if
  684.     %>
  685.     /*@if (@_jscript_version >= 1.3)
  686.         try 
  687.         {
  688.     @end @*/
  689.             if( childFrame.SetSelectedNode )
  690.             {
  691.                 childFrame.SetSelectedNode( "<%= strTOCEntry %>" );
  692.             }
  693.     /*@if (@_jscript_version >= 1.3)
  694.         } 
  695.         catch( e )
  696.         {
  697.             return;
  698.         }
  699.     @end @*/
  700.     }
  701.     <% jsCATCH %>
  702. }
  703. <%
  704.     end if
  705. End Sub
  706.  
  707. ''//////////////////////////////
  708. Sub DrawStdFooter()
  709.     if brMSIE = g_dwBrowserType then %>
  710. <script language="JavaScript">
  711. <% jsTRY %>
  712.     UpdateTreeViewSelection();
  713. <% jsCATCH %>
  714. </script>
  715. <script language="JScript" event=onclick for=window>
  716.     return false;
  717. </script>
  718. <!--
  719. <%= Server.HTMLEncode( L_COPYRIGHT_TEXT ) %>
  720. -->
  721. <%
  722.     end if
  723. End Sub
  724. %>
  725.